import Cookies from 'js-cookie'

const TokenKey = 'fenzhen_token'
const TimeOutKey = 'TimeOut' // 设置一个独一无二的token过期的key
const UserType = 'userType' // 设置type身份
const UserID = 'User_ID'
const UserName = 'userName'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// token过期的主动处理 获取时间戳
export function getTimeStamp() {
  return Cookies.get(TimeOutKey)
}

// 设置时间戳
export const setTimeStamp = () => {
  return Cookies.set(TimeOutKey, Date.now())
}

// 移除时间戳
export function removeTimeStamp(){
  return Cookies.remove(TimeOutKey)
}

// 设置type身份 
export function setUserType(userType){
      return Cookies.set(UserType,userType)
}

// 获取type身份
export function getUserType(){
  return Cookies.get(UserType)
}

// 移除type身份
export function removeUserType(){
  return Cookies.remove(UserType)
}

// 设置用户id
export function setUserID(id){
  return Cookies.set(UserID,id)
}

// 获取用户id
export function getUserID(){
return Cookies.get(UserID)
}

// 移除用户id
export function removeUserID(){
return Cookies.remove(UserID)
}

// 设置用户姓名
export function setUserName(userName){
  return Cookies.set(UserName,userName)
}

// 获取用户姓名
export function getUserName(){
return Cookies.get(UserName)
}

// 移除用户姓名
export function removeUserName(){
return Cookies.remove(UserName)
}